<!--
 * @Author: your name
 * @Date: 2020-09-03 23:40:09
 * @LastEditTime: 2020-09-04 09:54:05
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \暑期前端培训\13. Vue.js深入浅出\Vue.js深入浅出 01\跑马灯.html
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./lib/vue-2.4.0.js"></script>
  </head>
  <body>
    <div id="app">
      <input type="button" value="浪起来" @click="lang" />
      <input type="button" value="低调"  @click="stop"/>
      <h4>{{msg}}</h4>
      <h1 v-for="count in 10">{{count}}</h1>
    </div>
  </body>
  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        msg: "猥琐发育,别浪~~!",
        intervalid: null
      },
      methods: {
        lang() {

        if(this.intervalid != null) return

          this.intervalid = setInterval(() => {
            let start = this.msg.substring(0, 1);
            let end = this.msg.substring(1);
            this.msg = end + start;
          },300);

        },
        stop() {
            clearInterval(this.intervalid)
            this.intervalid = null

        }
      },
    });
  </script>
</html>
